package com.esri.core.renderer;

import com.esri.core.internal.util.d;
import com.esri.core.internal.util.g;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.jackson.JsonGenerator;

/* loaded from: classes.dex */
public class Colormap {
    private List<UniqueValue> a;

    public Colormap() {
        this.a = new ArrayList();
    }

    public Colormap(List<UniqueValue> list) {
        this.a = new ArrayList();
        this.a = list;
    }

    public List<UniqueValue> getUniqueValues() {
        return this.a;
    }

    public void setUniqueValues(List<UniqueValue> list) {
        this.a = list;
    }

    public int getMinValue() {
        List<UniqueValue> list = this.a;
        if (list == null || list.isEmpty()) {
            return Integer.MIN_VALUE;
        }
        int i = Integer.MAX_VALUE;
        for (UniqueValue uniqueValue : this.a) {
            if (uniqueValue.getPixelValue() < i) {
                i = uniqueValue.getPixelValue();
            }
        }
        return i;
    }

    public int getMaxValue() {
        List<UniqueValue> list = this.a;
        if (list == null || list.isEmpty()) {
            return Integer.MAX_VALUE;
        }
        int i = Integer.MIN_VALUE;
        for (UniqueValue uniqueValue : this.a) {
            if (uniqueValue.getPixelValue() > i) {
                i = uniqueValue.getPixelValue();
            }
        }
        return i;
    }

    public void addUniqueValue(UniqueValue uniqueValue) {
        this.a.add(uniqueValue);
    }

    public void removeUniqueValue(UniqueValue uniqueValue) {
        this.a.remove(uniqueValue);
    }

    public String toJson() throws Exception {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a = d.a(stringWriter);
        a.writeStartObject();
        toJson(a);
        a.writeEndObject();
        a.close();
        return stringWriter.toString();
    }

    /* JADX INFO: Access modifiers changed from: protected */
    public void toJson(JsonGenerator jsonGenerator) throws Exception {
        List<UniqueValue> list = this.a;
        if (list == null) {
            return;
        }
        int size = list.size();
        int[] iArr = new int[size];
        int[] iArr2 = new int[size];
        String[] strArr = new String[size];
        for (int i = 0; i < size; i++) {
            UniqueValue uniqueValue = this.a.get(i);
            iArr[i] = uniqueValue.getPixelValue();
            iArr2[i] = uniqueValue.getColor();
            strArr[i] = g.a(uniqueValue.getLabel()) ? "" : uniqueValue.getLabel();
        }
        d.a(jsonGenerator, "values", iArr);
        d.a(jsonGenerator, "colors", iArr2);
        d.a(jsonGenerator, "names", strArr);
    }

    /* loaded from: classes.dex */
    public static class UniqueValue {
        private int a;
        private int b;
        private String c;

        public UniqueValue(int i, int i2, String str) {
            this.a = i;
            this.b = i2;
            this.c = str;
        }

        public int getPixelValue() {
            return this.a;
        }

        public void setPixelValue(int i) {
            this.a = i;
        }

        public int getColor() {
            return this.b;
        }

        public void setColor(int i) {
            this.b = i;
        }

        public String getLabel() {
            return this.c;
        }

        public void setLabel(String str) {
            this.c = str;
        }
    }
}
